<%-- 
    Document   : sendMessage
    Created on : Mar 4, 2014, 10:36:09 PM
    Author     : Jordan,Theodoro
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" errorPage="error.jsp"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<c:set scope="request" var="title" value="Message"/>
<c:if test="${sessionScope.username == NULL}">
<c:redirect url="http://webtek.org/Bonix/index.php"/>
</c:if>
<sql:setDataSource user="root" password="" driver="com.mysql.jdbc.Driver"
                   url="jdbc:mysql://localhost/bonix"/>

<sql:update sql = "INSERT INTO messages(sender,receiver,msg,sent_date) VALUES (?,?,?,now())">
    <sql:param value="${fn:trim(sessionScope.username)}"/> 
    <sql:param value="${fn:trim(param.sender)}"/> 
    <sql:param value="${fn:trim(param.message)}"/>


</sql:update>
<c:url var="returnURL" value="viewConversation.jsp">
    <c:param name="sender" value="${param.sender}" />
</c:url>
<c:redirect url="${returnURL}" />
